package com.wingscode.modules.common.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wingscode.common.utils.PageUtils;
import com.wingscode.common.utils.Query;
import com.wingscode.modules.common.dao.AddedServiceDao;
import com.wingscode.modules.common.entity.AddedServiceEntity;
import com.wingscode.modules.common.service.AddedServiceService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


@Service("addedServiceService")
public class AddedServiceServiceImpl extends ServiceImpl<AddedServiceDao, AddedServiceEntity> implements AddedServiceService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = "";

        if (params.containsKey("name"))
            name = (String) params.get("name");

        IPage<AddedServiceEntity> page = this.page(
                new Query<AddedServiceEntity>().getPage(params),
                new QueryWrapper<AddedServiceEntity>()
                        .like(!StringUtils.isEmpty(name), "name", name)
                        .orderByAsc("sort")
                        .orderByDesc("id")
        );

        return new PageUtils(page);
    }

//    @Override
//    public void delete(Long[] ids){
//        this.removeByIds(Arrays.asList(ids));
//    }

}
